 function query(str,name,out,   \
                tmp,i,j,ands,ors,what,two) { 
   array(out)
   split(str, ands, /[ \t]+/)   # split the conjunctions on space
   for(i in ands) { 
     split(ands[i],two,/=/)     # split each conjunct on "="
     if (what = trim(name2col(two[1],name))) {
       split(two[2], ors,/,/)   # split each disjunst on ","
       for(j in ors) 
         out[what][trim(ors[j])] # add an item
     } else
       print "bad name " two[1] } 
 }
 function name2col(x,name,  i) { 
   for (i in name)  
     if (name[i] == x) # if you can find a name
       return i        # return its index
 }
 function ats(col,ors,at,new,active,   val,row,found) { 
   array(new)
   for(val in ors)           
     for(row in at[col][val]) # for the pair col=val 
       if(row in active) {    # return all rows with this pair
         found = 1
         new[row]["id"] = row
         new[row]["val"]++
       }
   return found
 }
